#ifndef __MOTOR_H
#define __MOTOR_H	

#include "pid.h"
#include "led.h"
#include "pwm.h"
#include "encoder.h"

typedef struct M1_CONTROLLER{  
	int speed;
	int pwm;
	int position;
	int input_speed;
	int set_speed;
	int set_potision;
	int roil;
} M1_CONTROLLER;


typedef struct M2_CONTROLLER{  
	int speed;
	int pwm;
	int position;
	int input_speed;
	int set_speed;
	int set_potision;
	int roil;
} M2_CONTROLLER;


typedef enum  {  
	 spd_foreward =0,
	 spd_backward =1,
	 pos_foreward =2,
	 pos_backward =3,
	 pos					=4,
	 spd_pos_foreward=5,
	 spd_pos_backward=6,
	 spd_pos =7,
	 cur_foreward =8,
	 cur_backward =9,
	 cur_spd_foreward=10,
	 M2_tracking_M1=11,
	 M1_tracking_M2=12,
	 M1_cur_spd_pos=13,
	 STOP=14,
	 M_state_MAX
}M_state;
extern M_state state;

#define M1_type 1  
#define M2_type 1  

#define Motor_roil_370 515 
#define Motor_roil_N20 1145 
#define Motor_roil_385 100 

#define M1_Enable 1  
#define M2_Enable 1  


void motor_control(void);
void spd_conversion(void);
void Motor_type(void);	
void M1_spd_control_foreward(void);
void M2_spd_control_foreward(void);
void M1_spd_control_backward(void);
void M2_spd_control_backward(void);

void M1_pos_control_foreward(void);
void M2_pos_control_foreward(void);
void M1_pos_control_backward(void);
void M2_pos_control_backward(void);

void M1_pos_control(void);
void M2_pos_control(void);

void M1_spd_pos_foreward_control(void);
void M2_spd_pos_foreward_control(void);

void M1_spd_pos_backward_control(void);
void M2_spd_pos_backward_control(void);

void M1_spd_pos_control(void);
void M2_spd_pos_control(void);

void M1_cur_foreward_control(void);
void M1_cur_backward_control(void);

void M1_cur_spd_foreward_control(void);

void M2_tracking_M1_control(void);
void M1_tracking_M2_control(void);

void M1_cur_spd_pos_control(void);
void M1_M2_STOP(void);
#endif
